package com.sun.dream.fish.config.shiro;

import com.sun.dream.fish.util.MD5Util;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * Description:  密码比较器
 * Created By ljl on 2023/12/11.
 */
public class DSFCredentialsMatcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken passwordToken = (UsernamePasswordToken) token;
        return MD5Util.decrypt(new String(passwordToken.getPassword()), (String) info.getCredentials());
    }
}
